﻿using System;
using System.Collections;
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLibrary.Entity;
using System.Collections.Generic;
using ClassLibrary.DAO;

public partial class Yumcha_UcControl_ucOrderDetails : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if ((Session[Global.SESSION_TOTAL] == null) || (Session[Global.SESSION_CART] == null))
            {
                Response.Redirect("~/Yumcha/Shopping_Cart.aspx");
            }
        }
    }
   
    protected void Button1_Click(object sender, EventArgs e)
    {
        
        if (!Page.IsValid) return;
        TblBooking booking ;
        TblCustomers account = new TblCustomers();

        if (Session[Global.SESSION_BOOK] == null)
            booking = new TblBooking();
        else
            booking = (TblBooking)Session[Global.SESSION_BOOK];

        if (Session[Global.SESSION_LOGGED_USER] != null)
            account = (TblCustomers)Session[Global.SESSION_LOGGED_USER];

        booking.Customer = account;
        booking.CusID = account.CusID;
        booking.DateBook = DateTime.Now;
        booking.DateEvent = Convert.ToDateTime(txt_day.Text);
        booking.Meal = drMeal.SelectedItem.Text;
        booking.IDType = 1;
        booking.Notes = txtNode.Text;
        booking.TimeEvent = drTime.SelectedItem.Text;
        booking.TotalPrice = Decimal.Parse(Session[Global.SESSION_TOTAL].ToString());
        booking.NumberPeople = Convert.ToInt32(cbNumberPoeple.SelectedItem.Text);

        Session[Global.SESSION_BOOK] = booking;

        Response.Redirect("~/Yumcha/ConfirmOrder.aspx");
    }
}
